package com.benyq.networkprogramme

import android.support.v4.app.Fragment
import android.support.v4.app.FragmentManager
import android.support.v4.app.FragmentPagerAdapter
import java.util.ArrayList

/**
 * @author benyq
 * @date 18-9-27 10:10
 * @E-mail： 1520063035@qq.com
 * @description
 */
class FragmentAdapter(fm: FragmentManager): FragmentPagerAdapter(fm) {

    private val fragmentList = mutableListOf<Fragment>()
    private val fragmentTitleList = mutableListOf<String>()

    override fun getItem(position: Int): Fragment {
        return fragmentList[position]
    }

    override fun getCount(): Int {
        return fragmentList.size
    }

    override fun getPageTitle(position: Int): CharSequence? {
        return fragmentTitleList[position]
    }

    fun addFragment(title: String, fragment: Fragment){
        fragmentList.add(fragment)
        fragmentTitleList.add(title)
    }
}